var names = [
	"曹瑞明",
	"陈德荣",
	"陈俊铭",
	"陈旗扬",
	"陈熙",
	"管政语",
	"何炜",
	"胡然",
	"黄惠华",
	"黄嘉俊",
	"贾军奥",
	"赖立昊",
	"林泽涛",
	"林子茸",
	"凌誉",
	"卢锦鹏",
	"卢子卫",
	"吕哲睿",
	"彭建瓴",
	"石铠兴",
	"孙鹏",
	"严杜锋",
	"杨俊铭",
	"叶子祺",
	"张远谋",
	"赵宇俊",
	"郑辰",
	"郑劭杰",
	"钟家奕",
	"曾茗悦",
	"陈思远",
	"邓怡婷",
	"付卓言",
	"高晓柔",
	"何诗晴",
	"胡绮曼",
	"梁洛熙",
	"刘佳玲",
	"骆梓煜",
	"欧晓栩",
	"丘夏瑶",
	"邱思琪",
	"石依晨",
	"许嘉笑",
	"杨佳怡",
	"叶嘉圆",
	"于佳琦",
	"张淑怡",
	"张雯希",
	"张译丹",
	"张羽菲",
	"张语婷",
	"郑欣然",
	"朱芷暄"
];

var drawname;
var index = -1;
var time;
var flag = 1;

function btnOnclick() {
	if (flag % 2 == 1) {
		begin();
		document.getElementById("BTN").value = "按A暂停";
	}
	if (flag % 2 == 0) {
		end();
		document.getElementById("BTN").value = "按A开始";
	}
	flag++;
}

function begin() {
	document.getElementById("BTN").disabled = false;
	draw();
}

function draw() {
	if (names.length > 0) {
		index = Math.floor(Math.random() * 1000 % names.length);
		drawname = names[index];
		document.getElementById("result").innerHTML = drawname;

		time = window.setTimeout(draw, 2);
	} else {
		document.getElementById("result").innerHTML = "~请刷新网页~";
	}
}

function speech() {
	var url = "https://fanyi.sogou.com/reventondc/synthesis?text=" + drawname +
		"&speed=0.7&lang=zh-CHS&from=translateweb&speaker=2";
	new Audio(url).play();
}

function end() {
	speech();
	window.clearTimeout(time);
	document.getElementById("BTN").disabled = false;
	names.splice(index, 1);
}